package com.imooc;

import com.imooc.controller.WelcomeController;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.support.SimpleInstantiationStrategy;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.lang.reflect.Constructor;

/**
 * <h1></h1>
 * {@link AbstractAutowireCapableBeanFactory#doCreateBean(String, RootBeanDefinition, Object[])}
 * 创建bean实例(工厂方法, 含参构造器注入, 无参构造器注入)
 * 		记录下呗@Autowired或者@Value标记的方法和成员变量
 * 			是否允许提前暴露
 * 				填充Bean属性
 * 					initializeBean
 * 					注册相关销毁逻辑
 * 						返回创建好的实例
 *
 *  {@link BeanWrapper} 用于修改bean属性
 *
 *
 * {@link AbstractAutowireCapableBeanFactory#createBeanInstance(String, RootBeanDefinition, Object[])}
 *
 * {@link AbstractAutowireCapableBeanFactory#instantiateUsingFactoryMethod(String, RootBeanDefinition, Object[])}
 *
 *
 * {@link org.springframework.beans.factory.support.ConstructorResolver#instantiateUsingFactoryMethod(String, RootBeanDefinition, Object[])}
 *
 * 带参数的构造函数
 * {@link AbstractAutowireCapableBeanFactory#autowireConstructor(String, RootBeanDefinition, Constructor[], Object[])}
 *
 * 默认构造器创建
 * {@link AbstractAutowireCapableBeanFactory#instantiateBean(String, RootBeanDefinition)}
 *
 *
 * {@link SimpleInstantiationStrategy#instantiate(RootBeanDefinition, String, BeanFactory)}
 * @author : dzj
 * @create: 2021-10-25 21:40
 */
@Configuration
@ComponentScan("com.imooc")
public class Debug0805_doCreateBean {
	public static void main(String[] args) {

		ApplicationContext ctx = new AnnotationConfigApplicationContext(Debug0805_doCreateBean.class);
		WelcomeController welcomeController = ctx.getBean(WelcomeController.class);
		welcomeController.handleRequest();

	}
}
